#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n, i, j, a[30][30], s1 = 0, s2 = 1;
    scanf("%d", &n);
    
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            scanf("%d", &a[i][j]);

    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
            if (i == j || (i + j == n - 1))  //判断该元素是否位于对角线上
            {
                s1 += a[i][j];  //两条对角线上各元素之和S1
                if ((i % 2 == 0 && j % 2 == 0))  //判断元素行列下标是否均为偶数
                    s2 *= a[i][j];
            }

    printf("%d", s1);
    printf(" %d\n", s2);

    for (i = 0; i < n; i++)  //控制列数
    {
        int count = 0;
        for (j = n - 1; j >= 0; j--)  //控制行数
        {
            if (count != 0)
                printf(" ");
            printf("%d", a[j][i]);
            count++;
        }
        printf("\n");  //一行打印结束,换行
    }
    return 0;
}